package com.sky.controller.admin;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("/admin/shop")
@RestController
public class AdminShopStatusController {
    @Autowired
    private RedisTemplate redisTemplate;

    @PutMapping("/{status}")
    public Result modifystatus(@PathVariable("status") Integer status)
    {
        log.info("店铺{}",status==1?"营业":"打烊");
        redisTemplate.opsForValue().set("status",status);
        return Result.success();
    }
    @GetMapping("/status")
    public Result getstatus()
    {
        Integer status = (Integer) redisTemplate.opsForValue().get("status");
        log.info("店铺{}",status==1?"营业":"打烊");
        return Result.success(status);
    }
}
